<template>
  <common-list-group>
    <template v-if="isHistory">
      <common-page title="查看历史">
        <el-button slot="header" @click="cancel(3)">返 回</el-button>
        <div slot="content" class="history" style="height: 100%">
          <common-table
            :data="historyList"
            style="overflow-x: hidden"
            @selection-change="handleSelectionChange2"
          >
            <el-table-column
              label="基线版本"
              align="left"
              prop="baseVersion"
              show-overflow-tooltip
              fixed
            />
            <!-- <el-table-column
              label="接口名称"
              align="left"
              prop="apiName"
              width="200px"
              show-overflow-tooltip
            /> -->
            <el-table-column
              label="路径"
              align="left"
              prop="path"
              show-overflow-tooltip
            />
            <el-table-column label="流量基数" align="left" prop="baselineNum">
              <template slot-scope="scope">
                {{ scope.row.baselineNum ? scope.row.baselineNum : 0 }}KB
              </template>
            </el-table-column>
            <!-- <el-table-column
              label="协议"
              align="left"
              prop="schemaProtocol"
              width="80px"
            />
            <el-table-column
              label="域名IP"
              align="left"
              prop="domainIp"
              width="160px"
            />
            <el-table-column
              label="端口"
              align="left"
              prop="port"
              width="80px"
            /> -->

            <!-- <el-table-column
              label="参数"
              align="left"
              prop="query"
              show-overflow-tooltip
            /> -->
            <el-table-column
              label="创建时间"
              align="left"
              prop="createTime"
              width="160px"
            />
            <!-- <el-table-column
              label="操作"
              align="center"
              width="80px"
              fixed="right"
            >
              <template slot-scope="scope">
                <el-button type="text" @click="getInfo(scope.row, 2)">
                  详情
                </el-button>
              </template>
            </el-table-column> -->
          </common-table>
        </div>

        <div slot="pagination">
          <pagination
            :total="total2"
            :page.sync="queryParams2.pageNum"
            :limit.sync="queryParams2.pageSize"
            @pagination="histroyList"
            v-show="total2 > 0"
          />
        </div>
        <common-info-dialog
          :title="detailsTitle"
          :visible.sync="detailsOpen"
          @cancel="cancel(2)"
          :infoLoading="infoLoading"
        >
          <common-info-table>
            <common-info-table-cell label="基线版本"
              >{{ form.baseVersion }}
            </common-info-table-cell>
            <common-info-table-cell label="接口名称"
              >{{ form.apiName }}
            </common-info-table-cell>
            <common-info-table-cell label="流量基数"
              >{{ form.baselineNum }}KB
            </common-info-table-cell>

            <common-info-table-cell label="协议"
              >{{ form.schemaProtocol }}
            </common-info-table-cell>
            <common-info-table-cell label="域名IP"
              >{{ form.domainIp }}
            </common-info-table-cell>
            <common-info-table-cell label="端口"
              >{{ form.port }}
            </common-info-table-cell>
            <common-info-table-cell label="路径"
              >{{ form.path }}
            </common-info-table-cell>
            <!-- <common-info-table-cell label="参数"
              >{{ form.query }}
            </common-info-table-cell>
            <common-info-table-cell label="方法"
              >{{ form.method }}
            </common-info-table-cell>
            <common-info-table-cell label="BODY"
              >{{ form.body }}
            </common-info-table-cell>
            <common-info-table-cell label="请求头信息"
              >{{ form.requestHead }}
            </common-info-table-cell> -->
          </common-info-table>
        </common-info-dialog>
      </common-page>
    </template>
    <template>
      <div slot="group" class="group-list-component-wrap">
        <common-tree
          ref="treeRef"
          :is-slot="true"
          :isRequest="isRequest"
          :treeLoading="treeLoading"
          :tree-data="applitionTreeData"
          :defaultExpandAll="false"
          :defaultExpandedKeys="defaultExpandedKeys"
          :tree-prop="{
            label: 'orgName',
          }"
          is-show-icon-for-no-child
          searchForChildren
          search-placeholder="查询分组或者业务系统"
          :current-node-key="currentNodeKey"
          nodeKey="orgId"
          set-node-by-key="isLeaf"
          special-use="API"
          @handleNodeExpand="handleNodeExpand"
          @handleNodeClick="handleTreeNodeClick"
        >
          <div slot-scope="{ scope }" class="tree-item-wrap">
            <common-carousel-text
              :content="scope.data.orgName"
              :font-size="14"
            />
            <el-popover
              v-if="
                scope.data.type === '2' ||
                ((scope.data.isDefault !== '1' || scope.node.level === 1) &&
                  (scope.data.type === '0' ||
                    (scope.node.level > 1 &&
                      (isAdmin || scope.data.createBy === name))))
              "
              popper-class="chart-type-list-popover"
              placement="right-start"
              width="150"
              trigger="hover"
            >
              <commonIcon
                iconName="icon-more"
                slot="reference"
                iconType="icon"
                :iconSize="16"
              ></commonIcon>
              <common-menu>
                <common-menu-item
                  v-if="scope.data.type === '0'"
                  @click="addType(scope.data)"
                  >新增子分类
                </common-menu-item>
                <div v-if="isAdmin || scope.data.createBy === name">
                  <common-menu-item
                    v-if="scope.data.type === '0'"
                    @click="addApplication(scope.data)"
                    >业务系统管理
                  </common-menu-item>
                  <common-menu-item
                    v-if="scope.data.type === '0' && scope.node.level > 1"
                    @click="editType(scope.data)"
                    >重命名
                  </common-menu-item>
                  <common-menu-item
                    v-if="scope.node.level > 1 && scope.data.type !== '2'"
                    @click="handleDeleteTree(scope.data)"
                    >{{ scope.data.type === "0" ? "删除" : "解绑" }}
                  </common-menu-item>
                </div>
                <common-menu-item
                  v-if="scope.node.level > 1 && scope.data.type === '2'"
                  @click="handleThreshold(scope.data)"
                  v-hasPermi="['apisecurity:baseline:uplinkEdit']"
                  >设置阈值
                </common-menu-item>
              </common-menu>
            </el-popover>
          </div>
        </common-tree>
      </div>
      <common-search slot="search" @search="handleQuery" @reset="resetQuery">
        <el-form
          @submit.native.prevent
          :model="queryParams"
          ref="queryForm"
          :inline="true"
          v-show="showSearch"
          label-width="65px"
        >
          <el-form-item label="基线版本" prop="baseVersion">
            <common-input
              :maxlength="256"
              :verify="false"
              @enter="handleQuery"
              v-model="queryParams.baseVersion"
              clearable
            />
          </el-form-item>

          <el-form-item label="域名IP" prop="domainIp">
            <common-input
              :maxlength="256"
              :verify="false"
              @enter="handleQuery"
              v-model="queryParams.domainIp"
              clearable
            />
          </el-form-item>
          <el-form-item label="端口" prop="port">
            <common-input
              :verify="false"
              @enter="handleQuery"
              v-model="queryParams.port"
              clearable
            />
          </el-form-item>

          <el-form-item label="创建时间">
            <el-date-picker
              v-model="date"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              value-format="yyyy-MM-dd"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-form>
      </common-search>
      <el-row :gutter="10" class="mb8" slot="tools">
        <el-col :span="1.5">
          <el-button
            :loading="baselineBtnLoading"
            type="primary"
            plain
            icon="el-icon-plus"
            @click="handleBaseline"
            v-hasPermi="['apisecurity:baseline:uplinkAdd']"
          >
            生成基线
          </el-button>
        </el-col>
      </el-row>

      <common-table
        slot="content"
        v-loading="loading"
        :data="baselineList"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          label="基线版本"
          align="left"
          prop="baseVersion"
          width="240px"
          fixed="left"
          show-overflow-tooltip
        />
        <el-table-column
          label="协议"
          align="center"
          prop="schemaProtocol"
          width="80px"
        />
        <el-table-column
          label="流量基数"
          align="center"
          prop="baselineNum"
          width="80px"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            {{ scope.row.baselineNum ? scope.row.baselineNum : 0 }}KB
          </template>
        </el-table-column>
        <el-table-column
          label="变更阈值"
          align="center"
          prop="baselineChange"
          width="80px"
        >
          <template slot-scope="scope">
            {{ scope.row.baselineChange ? scope.row.baselineChange : 0 }}%
          </template>
        </el-table-column>
        <el-table-column
          label="告警阈值"
          align="center"
          prop="baselineWarning"
          width="120px"
        >
          <template slot-scope="scope">
            {{ scope.row.baselineWarning ? scope.row.baselineWarning : 0 }}%
          </template>
        </el-table-column>
        <el-table-column
          label="路径"
          align="left"
          prop="path"
          show-overflow-tooltip
        />
        <el-table-column
          label="创建时间"
          align="left"
          prop="createTime"
          width="160px"
          show-overflow-tooltip
        />
        <!-- <el-table-column
          label="组织"
          align="left"
          prop="deptName"
          width="180"
          show-overflow-tooltip
        >
        </el-table-column> -->
        <el-table-column label="操作" align="left" width="170" fixed="right">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="edit(scope.row)"
              v-hasPermi="['apisecurity:baseline:uplinkEdit']"
            >
              设置阈值
            </el-button>

            <el-button
              type="text"
              @click="getInfo(scope.row, 1)"
              v-hasPermi="['apisecurity:baseline:uplink']"
            >
              详情
            </el-button>

            <el-button
              type="text"
              @click="lookHistory(scope.row)"
              v-hasPermi="['apisecurity:histroy:uplink']"
              >查看历史
            </el-button>
          </template>
        </el-table-column>
      </common-table>

      <pagination
        slot="pagination"
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
      <!-- 详情 -->
      <common-info-dialog
        :title="detailsTitle"
        :visible.sync="detailsOpen"
        @cancel="cancel(2)"
        :infoLoading="infoLoading"
      >
        <common-info-table>
          <common-info-table-cell label="基线版本"
            >{{ form.baseVersion }}
          </common-info-table-cell>
          <common-info-table-cell label="接口名称"
            >{{ form.apiName }}
          </common-info-table-cell>
          <common-info-table-cell label="流量基数"
            >{{ form.baselineNum }}KB
          </common-info-table-cell>

          <common-info-table-cell label="协议"
            >{{ form.schemaProtocol }}
          </common-info-table-cell>
          <common-info-table-cell label="域名IP"
            >{{ form.domainIp }}
          </common-info-table-cell>
          <common-info-table-cell label="端口"
            >{{ form.port }}
          </common-info-table-cell>
          <common-info-table-cell label="路径"
            >{{ form.path }}
          </common-info-table-cell>
          <!-- <common-info-table-cell label="参数"
            >{{ form.query }}
          </common-info-table-cell>
          <common-info-table-cell label="方法"
            >{{ form.method }}
          </common-info-table-cell>
          <common-info-table-cell label="BODY"
            >{{ form.body }}
          </common-info-table-cell>
          <common-info-table-cell label="请求头信息"
            >{{ form.requestHead }}
          </common-info-table-cell> -->
          <!-- <common-info-table-cell label="组织"
            >{{ form.deptName }}
          </common-info-table-cell> -->
          <common-info-table-cell label="所属分组"
            >{{ form.ancestors }}
          </common-info-table-cell>
        </common-info-table>
      </common-info-dialog>

      <common-edit-dialog
        :visible="isEditDialogs"
        title="批量设置阈值"
        :button-loading="buttonLoadings"
        @cancel="editDialogCancels"
        @submit="editDialogSubmits"
      >
        <el-form ref="editForms" :model="editForms" label-width="73px">
          <el-row :gutter="18">
            <el-col :span="12">
              <el-form-item
                label="告警阈值"
                prop="baselineWarning"
                :rules="[
                  {
                    required: true,
                    message: '请输入告警阈值',
                    trigger: 'blur',
                  },
                  {
                    type: 'number',
                    min: 1,
                    max: 99999,
                    message: '告警阈值范围 1-99999',
                    trigger: 'blur',
                  },
                ]"
              >
                <common-input-number
                  :max-length="6"
                  style="width: calc(100% - 20px)"
                  v-model="editForms.baselineWarning"
                />
                %
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="变更阈值"
                prop="baselineChange"
                :rules="[
                  {
                    required: true,
                    message: '请输入变更阈值',
                    trigger: 'blur',
                  },
                  {
                    type: 'number',
                    min: 1,
                    max: 99999,
                    message: '变更阈值范围 1-99999',
                    trigger: 'blur',
                  },
                ]"
              >
                <common-input-number
                  :max-length="6"
                  style="width: calc(100% - 20px)"
                  v-model="editForms.baselineChange"
                />
                %
              </el-form-item>
            </el-col>
            <!-- <el-col :span="12">
              <common-add-dept
                ref="commonAddDept"
                :deptListParams="deptListParams"
                @getCheckedDeptId="getCheckedDeptId"
                :deptId="editForm.deptId"
              ></common-add-dept>
            </el-col> -->
          </el-row>
        </el-form>
      </common-edit-dialog>
      <common-edit-dialog
        :visible="isEditDialog"
        title="设置阈值"
        :button-loading="buttonLoading"
        @cancel="editDialogCancel"
        @submit="editDialogSubmit"
      >
        <el-form
          ref="editForm"
          :model="editForm"
          :rules="editFormRules"
          label-width="73px"
        >
          <el-row :gutter="18">
            <!-- <el-col :span="24">
              <el-form-item label="类型" prop="baselineWarning">
                <el-select
                  v-model="form.baseType"
                  placeholder="请选择"
                  style="width: 100%"
                  clearable
                >
                  <el-option
                    v-for="item in typeList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col> -->
            <el-col :span="12">
              <el-form-item label="告警阈值" prop="baselineWarning">
                <common-input-number
                  :max-length="5"
                  style="width: calc(100% - 20px)"
                  v-model="editForm.baselineWarning"
                />
                %
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="变更阈值" prop="baselineChange">
                <common-input-number
                  :max-length="5"
                  style="width: calc(100% - 20px)"
                  v-model="editForm.baselineChange"
                />
                %
              </el-form-item>
            </el-col>
            <!-- <el-col :span="12">
              <common-add-dept
                ref="commonAddDept"
                :deptListParams="deptListParams"
                @getCheckedDeptId="getCheckedDeptId"
                :deptId="editForm.deptId"
              ></common-add-dept>
            </el-col> -->
          </el-row>
        </el-form>
      </common-edit-dialog>
      <!-- 应用 多选弹窗 -->
      <choose-multiple
        ref="chooseMultiple"
        @refresh="refresh"
      ></choose-multiple>

      <!-- 新增/编辑子分类弹窗 -->

      <common-edit-dialog
        :title="`${isTypeEdit ? '重命名' : '新增子分类'}`"
        :visible="isTypeDialog"
        :button-loading="dialogLoading"
        @cancel="cancelTypeForm"
        @submit="submitTypeForm"
        width="25%"
      >
        <el-form
          ref="typeForm"
          :model="typeForm"
          :rules="typeRule"
          label-width="80px"
          @submit.native.prevent
        >
          <el-form-item label="分类名称" prop="orgName">
            <common-input
              :maxlength="20"
              v-model="typeForm.orgName"
            ></common-input>
          </el-form-item>
        </el-form>
      </common-edit-dialog>
    </template>
  </common-list-group>
</template>

<script>
import {
  listBaseline,
  addBaseline,
  updateBaseline,
  getBaseline,
  histroyList,
  getHistoryline,
  getApiBaselineStatus,
  editbyapl,
} from "@/api/apisecurity/apibaseline/baseline";
import { decode } from "@/utils/aesUtils";
import BaseList from "@/mixins/BaseList";
import Index from "../apiinterface/mixin/index";
import Template from "../../msgService/email/template.vue";
import { getSingleArray, getFullDept } from "@/utils/util";
import { mapGetters } from "vuex";
import commonIcon from "@/components/CommonIcon";
import ChooseMultiple from "../apiinterface/components/chooseMultiple.vue";

export default {
  name: "Baseline",
  components: { Template, commonIcon, ChooseMultiple },
  mixins: [BaseList, Index],
  data() {
    return {
      singleDeptList: [],
      currentParent: 3,
      infoLoading: false,
      isHistory: false,
      date: [],
      showSearch: true,
      loading: true,
      baselineList: [],
      baseId: "",
      historyList: [],
      title: "",
      detailsTitle: "",
      open: false,
      detailsOpen: false,
      baselineBtnLoading: false,
      total: 0,
      total2: 0,
      // 查询参数
      queryParams: {
        port: null,
        domainIp: null,
        apiName: null,
        baseVersion: null,
        pageNum: 1,
        pageSize: 10,
        deptIds: null,
        baselineType: 0,
        baseType: null,
      },
      queryParams2: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      editForm: {
        baselineWarning: 0,
        baselineChange: 0,
      },
      editForms: {
        baseType: null,
        baselineWarning: 0,
        baselineChange: 0,
      },
      editFormRules: {
        baselineWarning: [
          { required: true, message: "请输入告警阈值", trigger: "blur" },
          {
            type: "number",
            min: 1,
            max: 99999,
            message: "告警阈值范围 1-99999",
            trigger: "blur",
          },
        ],
        baselineChange: [
          { required: true, message: "请输入变更阈值", trigger: "blur" },
          {
            type: "number",
            min: 1,
            max: 99999,
            message: "变更阈值范围 1-99999",
            trigger: "blur",
          },
        ],
      },
      isEditDialog: false,
      isEditDialogs: false,
      deptListParams: [],
      buttonLoading: false,
      buttonLoadings: false,
      applitionTreeData: [],
      treeLoading: true,
      currentNodeKey: "",
      aplManageId: "",
      isRequest: false,
    };
  },
  computed: {
    ...mapGetters(["isAdmin", "name"]),
  },
  created() {
    this.getApplicationList();
    this.getList();
  },
  methods: {
    getLoading() {
      this.loading = true;
    },
    getCheckedDeptId(val) {
      this.editForm.deptId = val;
    },
    // getDeptList(list) {
    //   this.deptListParams = list;
    //   this.singleDeptList = getSingleArray(list);
    //   this.getList();
    //   this.getApplicationList();
    // },
    // getDeptId(val) {
    //   this.queryParams.deptIds = val;
    // },
    // getDeptName(val) {
    //   let dept = this.singleDeptList.find((item) => item.id === val.toString());
    //   if (dept) return getFullDept(dept.fulllabel);
    // },
    editDialogCancel() {
      this.isEditDialog = false;
      this.editForm.id = null;
      this.editForm.baselineWarning = 0;
      this.editForm.baselineChange = 0;
      this.editForm.deptId = undefined;
    },
    editDialogCancels() {
      this.isEditDialogs = false;
      this.editForms.id = null;
      this.editForms.baselineWarning = 0;
      this.editForms.baselineChange = 0;
    },
    editDialogSubmit() {
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.buttonLoading = true;
          updateBaseline(this.editForm)
            .then((res) => {
              if (res && res.code === 200) {
                this.editDialogCancel();
                this.$GlobalSuccessMessage("编辑成功");
                this.getList();
              } else {
                this.$GlobalErrorConfirm("编辑失败", res.msg);
              }
            })
            .finally(() => {
              this.buttonLoading = false;
            });
        }
      });
    },
    editDialogSubmits() {
      this.$refs.editForms.validate((valid) => {
        if (valid) {
          this.buttonLoadings = true;

          editbyapl({ ...this.editForms, aplManageId: this.aplManageId })
            .then((res) => {
              if (res && res.code === 200) {
                this.editDialogCancel();
                this.$GlobalSuccessMessage("编辑成功");
                this.isEditDialogs = false;
                this.getList();
              } else {
                this.$GlobalErrorConfirm("编辑失败", res.msg);
              }
            })
            .finally(() => {
              this.buttonLoadings = false;
            });
        }
      });
    },
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    handleSelectionChange2(selection) {
      // console.log(selection);
      // this.ids = selection.map((item) => item.id);
    },
    getList() {
      this.loading = true;

      if (this.date && this.date.length > 0) {
        this.queryParams.beginTime = this.date[0];
        this.queryParams.endTime = this.date[1];
      } else {
        this.queryParams.beginTime = null;
        this.queryParams.endTime = null;
      }
      let params = {
        ...this.queryParams,
        orgId: this.orgId,
        businessSystemId: this.businessSystemId,
        aplManageId: this.appId,
        baseType: 1,
      };
      listBaseline(params).then((res) => {
        this.loading = false;
        if (res && res.code === 200) {
          this.baselineList = res.rows;

          //path传输解密
          if (this.baselineList.length > 0) {
            this.baselineList.map((baseline) => {
              baseline.path = decode(baseline.path);
              return baseline;
            });
          }
          // this.baselineList.forEach((item) => {
          //   item.deptName = this.getDeptName(item.deptId || "");
          // });

          this.total = res.total;
        } else {
          this.baselineList = [];
          this.total = 0;
          this.handleListTips(res);
        }
      });
    },

    /** 查询按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      // this.$refs.commonDept.clearDept();
      this.queryParams = this.$options.data().queryParams;
      this.date = [];
    },
    // 取消按钮
    cancel(n) {
      if (n === 1) {
        this.open = false;
      } else if (n === 2) {
        this.detailsOpen = false;
      } else {
        this.isHistory = false;
        this.$emit("changeTitle", true);
      }
    },
    lookHistory(row) {
      this.isHistory = true;
      this.queryParams2.pageNum = 1;
      this.baseId = row.id;
      this.histroyList();
      this.$emit("changeTitle", false);
    },
    histroyList() {
      const params = Object.assign(
        {},
        { baseId: this.baseId },
        this.queryParams2
      );
      histroyList(params).then((res) => {
        if (res && res.code === 200) {
          this.total2 = res.total;
          this.historyList = res.rows;
        } else {
          this.total2 = 0;
          this.historyList = [];
          this.handleListTips(res);
        }
      });
    },
    edit(row) {
      console.log("row: ", row);
      this.editForm.id = row.id;
      this.editForm.baselineWarning = row.baselineWarning;
      this.editForm.baselineChange = row.baselineChange;
      this.editForm.deptId = row.deptId;

      this.isEditDialog = true;
    },
    handleThreshold(row) {
      this.aplManageId = row.appId;
      this.editForms.baseType = 1;
      this.editForms.baselineWarning = 0;
      this.editForms.baselineChange = 0;
      this.isEditDialogs = true;
    },

    getInfo(row, n) {
      const id = row.id;
      let functionName = getBaseline;
      if (n === 2) {
        functionName = getHistoryline;
        this.open = true;
      }
      this.infoLoading = true;
      functionName(id).then((res) => {
        if (res && res.code === 200) {
          this.form = res.data;
          // this.form.deptName = this.getDeptName(this.form.deptId || "");
          this.detailsOpen = true;
          if (n === 1) {
            this.form.requestHead = decode(this.form.requestHead);
            this.detailsTitle = "基线详情";
          } else {
            this.detailsTitle = "历史详情";
          }
          this.infoLoading = false;
        } else {
          this.$GlobalErrorConfirm("获取详情失败", res.msg, "重新加载").then(
            () => {
              this.getInfo(row, n);
            }
          );
        }
      });
    },

    handleBaseline() {
      this.getApiBaselineStatus().then((res) => {
        if (res.code === 200) {
          // 1: 成功 2: 失败 0: 进行中

          if (res.data === 0) {
            this.$GlobalErrorConfirm("警告", "基线生成中,请稍后再试!");
          } else {
            this.addBaseline();
          }
        } else {
          this.addBaseline();
        }
      });
    },

    addBaseline() {
      this.baselineBtnLoading = true;
      addBaseline({ baselineType: 0, baseType: 1 })
        .then((res) => {
          if (res && res.code === 200) {
            this.$GlobalSuccessMessage("基线生成中");
            this.getList();
          } else {
            this.$GlobalErrorConfirm("生成基线失败", res.msg);
          }
        })
        .finally(() => {
          this.baselineBtnLoading = false;
        });
    },
    getApiBaselineStatus() {
      return new Promise((resolve, reject) => {
        getApiBaselineStatus().then((res) => {
          resolve(res);
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.history {
  padding: 18px;
}

.tree-item-wrap {
  display: flex;
  align-items: center;
  width: 100%;

  &:hover {
    .iconfont {
      opacity: 1;
    }
  }

  .iconfont {
    opacity: 0;
    transition: opacity 0.15s linear;
  }
}
</style>
